-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose import mode calculation functions #49360
Expose import mode calculation functions #49360
Conversation
@iclanton given changes at microsoft/rushstack#3434, you might want to move that out from |
src/compiler/program.ts
Outdated
* If you have an actual import node, prefer using getModeForUsageLocation on the reference string node. | ||
* @param file File to fetch the resolution mode within | ||
* @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations | ||
*/ | ||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea:
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number) { | |
export function getModeForResolutionAtIndex(file: SourceFile, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined; | |
/** @internal */ | |
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined; | |
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined { |
Then you don't have to expose SourceFileImportsList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed the changes since I think we should get this into 4.7.3.
@typescript-bot cherry-pick this to release-4.7 |
Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into |
Hey @DanielRosenwasser, I've opened #49370 for you. |
…e-4.7 (#49370) * Cherry-pick PR #49360 into release-4.7 Component commits: 5eb6425 Expose import mode calculation functions 1f907ae Make `SourceFileImportsList` internal again. 4e40185 Accepted API baselines. * Fix lints. Co-authored-by: Daniel Rosenwasser <[email protected]> Co-authored-by: Daniel Rosenwasser <[email protected]>
Fixes #49340
getModeForUsageLocation
should be the preferred function, however you may need to resort togetModeForResolutionAtIndex
in some implementations ofresolveModuleNames
(though it's potentially unable to handle partial name lists).